/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import entity.StackUser;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.enterprise.context.ApplicationScoped;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Root;
import sessionbean.UserFacade;

/**
 *
 * @author wei
 */
@Singleton
@Startup
@ApplicationScoped
public class DataInitializer {

    @PersistenceContext(unitName = "CuteOverflow-warPU")
    private EntityManager em;

    @PostConstruct
    public void initialize() throws IOException {
        System.out.println("initializing...");
                
        StackUser artem = new StackUser();
        artem.setStackId("859536");
        artem.setEmail("devilfromrussia@gmail.com");
        em.persist(artem);
        
        StackUser passerby = new StackUser();
        passerby.setStackId("849506");
        em.persist(passerby);
        
        StackUser wei = new StackUser();
        wei.setEmail("luwei.here@gmail.com");
        wei.setStackId("429288");
        wei.getFollowing().add(artem);
        wei.getFollowing().add(passerby);
        wei.getFollowing().add(wei);
        em.persist(wei);
        
        artem.getFollowing().add(wei);
        
    }

}
